<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <ui:composition template="/shared/_layout.xhtml">
        <ui:define name="title">
            <h:outputText value="#{lang._account_profil_title}"/>
        </ui:define>
        <ui:define name="css">
            <h:outputStylesheet name="form.css" library="css" />
            <h:outputStylesheet name="index.css" library="css/account" />
        </ui:define>
        <ui:define name="content">
            <f:event listener="#{account.isNotLogged()}" type="preRenderView" />
            <article>
                <h1>
                    <h:outputText value="#{lang._account_profil_welcome}"/>
                    <h:outputText value="#{account.user.firstname}"/>, 
                    <h:outputText value="#{account.user.lastname}"/>
                </h1>
                <section>
                    <h2>
                        <h:outputText value="#{lang._account_profil_informations}"/>
                    </h2>
                    <p>
                        <table>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._account_profil_address}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.address}"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._account_profil_zipcode}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.zip}"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._account_profil_city}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.city}"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._account_profil_country}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.country}"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._account_profil_email}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.email}"/>
                                </td>
                            </tr>
                        </table>
                    </p>
                </section>
                <c:if test="#{account.orders.size() > 0}">
                    <section>
                        <h2>
                            <h:outputText value="#{lang._account_profil_commands}"/>
                        </h2>
                        <h:dataTable value="#{account.orders}" var="entry" id="orders" columnClasses="orders-id, orders-name, orders-quantity, orders-price, orders-status">
                            <h:column>
                                <f:facet name="header">ID</f:facet>
                                #<h:outputText value="#{entry.idOrders.IDorders}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">Nom</f:facet>
                                <h:outputText value="#{entry.idArticles.name}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">Quantité</f:facet>
                                <h:outputText value="#{entry.quantityArticle}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">Prix T.T.C.</f:facet>
                                <h:outputText value="#{entry.idOrders.netAmount}€"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">Status</f:facet>
                                <h:outputText value="#{account.getOrderStatus(entry.idOrders.status)}"/>
                            </h:column>
                        </h:dataTable>
                    </section>
                </c:if>
                <section>
                    <h2>
                        <h:outputText value="#{lang._account_profil_logout}"/>
                    </h2>
                    <p>
                        <h:outputText value="#{lang._account_profil_logout_description}"/>
                    </p>
                    <h:form>
                        <p>
                            <h:commandButton action="#{account.logout()}"
                                             value="#{lang._account_profil_logout}"/>
                        </p>
                    </h:form>
                </section>
            </article>
        </ui:define>
    </ui:composition>
</html>